<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="../Connections/A146240Connection.jsp" %>
<%
// *** Restrict Access To Page: Grant or deny access to this page
String MM_authorizedUsers="146240,151945,152786,153948";
String MM_authFailedURL="../login.jsp";
boolean MM_grantAccess=false;
if (session.getValue("MM_Username") != null && !session.getValue("MM_Username").equals("")) {
  if (false || (session.getValue("MM_UserAuthorization")=="") || 
          (MM_authorizedUsers.indexOf((String)session.getValue("MM_UserAuthorization")) >=0)) {
    MM_grantAccess = true;
  }
}
if (!MM_grantAccess) {
  String MM_qsChar = "?";
  if (MM_authFailedURL.indexOf("?") >= 0) MM_qsChar = "&";
  String MM_referrer = request.getRequestURI();
  if (request.getQueryString() != null) MM_referrer = MM_referrer + "?" + request.getQueryString();
  MM_authFailedURL = MM_authFailedURL + MM_qsChar + "accessdenied=" + java.net.URLEncoder.encode(MM_referrer);
  response.sendRedirect(response.encodeRedirectURL(MM_authFailedURL));
  return;
}
%>
<%
Driver DriverRecordset1 = (Driver)Class.forName(MM_A146240Connection_DRIVER).newInstance();
Connection ConnRecordset1 = DriverManager.getConnection(MM_A146240Connection_STRING,MM_A146240Connection_USERNAME,MM_A146240Connection_PASSWORD);
PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM A152786.PRODUCT ORDER BY PRODUCT_ID");
ResultSet Recordset1 = StatementRecordset1.executeQuery();
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
Object Recordset1_data;
int Recordset1_numRows = 0;
%>
<%
int Repeat1__numRows = 10;
int Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="productStyle.css" />
<title>POWA Store [manage item]</title>
</head>

<body>
<div id="main_content" align="center">
<table border="1">
  <tr>
	<td>Picture</td>
    <td>Product ID</td>
    <td>Product Name</td>
    <td>Product Description</td>
    <td>Product Quantity</td>
    <td>Product Price</td>
    <td>Product Cost</td>
  </tr>
  <% while ((Recordset1_hasData)&&(Repeat1__numRows-- != 0)) { 
  %>
  <tr>
	<td>
    <img src="productImages/<%=(((Recordset1_data = Recordset1.getObject("PRODUCT_NAME"))==null || Recordset1.wasNull())?"":Recordset1_data)%>.gif" width="80px" height="158px"/></td>
    <td>
	  <div align="center"><a href="editProduct.jsp?&PRODUCT_ID=<%=(((Recordset1_data = Recordset1.getObject("PRODUCT_ID"))==null || Recordset1.wasNull())?"":Recordset1_data)%>"> <%=(((Recordset1_data = Recordset1.getObject("PRODUCT_ID"))==null || Recordset1.wasNull())?"":Recordset1_data)%></a> </div></td>
    <td><div align="center"><%=(((Recordset1_data = Recordset1.getObject("PRODUCT_NAME"))==null || Recordset1.wasNull())?"":Recordset1_data)%></div></td>
    <td><pre><%=(((Recordset1_data = Recordset1.getObject("PRODUCT_DESC"))==null || Recordset1.wasNull())?"":Recordset1_data)%></pre></td>
    <td><div align="center"><%=(((Recordset1_data = Recordset1.getObject("PRODUCT_QUANTITY"))==null || Recordset1.wasNull())?"":Recordset1_data)%></div></td>
    <td><div align="center">RM <%=(((Recordset1_data = Recordset1.getObject("PRODUCT_PRICE"))==null || Recordset1.wasNull())?"":Recordset1_data)%></div></td>
    <td><div align="center">RM <%=(((Recordset1_data = Recordset1.getObject("PRODUCT_COST"))==null || Recordset1.wasNull())?"":Recordset1_data)%></div></td>
  </tr>
  <%
  Repeat1__index++;
  Recordset1_hasData = Recordset1.next();
}
%>
<tr><td colspan="7"><div align="center">
  <form action="createNewProduct.jsp" method="post" name="insertNewForm" id="insertNewForm">
    <input type="submit" name="Submit" value="Add New Product">
    </form>
  </div></td>
</tr>
</table>
</div>
</body>
</html>
<%
Recordset1.close();
StatementRecordset1.close();
ConnRecordset1.close();
%>
